/**
 * @(#)MyProtoHandler.java, 2018/12/26
 * <p/>
 * Copyright 2018 Netease, Inc. All rights reserved.
 * NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.chengzhi.netty.protobuf;

import com.chengzhi.netty.proto.SubscribeResqProto;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author 阮承志(wb.ruanchengzhi @ mesg.corp.netease.com)
 **/
public class MyProtoServerHandler extends SimpleChannelInboundHandler<MyMessageDTO.MyMessage> {


    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MyMessageDTO.MyMessage msg) throws Exception {
        MyMessageDTO.MyMessage.dataType dataType = msg.getDataType();
        if (dataType == MyMessageDTO.MyMessage.dataType.PersonType)
            System.out.println("person---------");
        else if (dataType == MyMessageDTO.MyMessage.dataType.StudentType)
            System.out.println("student----------");
    }

    private SubscribeResqProto.SubscribeResq resp(int subReqId) {
        SubscribeResqProto.SubscribeResq.Builder builder = SubscribeResqProto.SubscribeResq.newBuilder();
        builder.setSubReqId(subReqId);
        builder.setRespCode(0);
        builder.setDesc("netty book order succeed, 3 days later, sent to the designted address");
        return builder.build();
    }
}
